<template>
    <h3>登录页面</h3>
    <table>
        <tr>
            <td>用户名</td>
            <td>
                <input type="text" v-model="info.name"/>
            </td>
        </tr>
        <tr>
            <td>密码</td>
            <td>
                <input type="password" v-model="info.pwd"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button" value="登录" @click="add"/>
            </td>
        </tr>
    </table>
</template>

<script setup lang="ts">
import { ref,onMounted } from 'vue';
import axios from 'axios';
import router from '@/router';
const info=ref({
    name:"",
    pwd:""
})
const add=()=>{
    axios.get("https://localhost:7237/api/user/login?name="+info.value.name+"&pwd="+info.value.pwd).then(res=>{
        if(res.data==-1){
            alert('用户名不存在');
        }
        else if(res.data>0){
            alert('成功');
            router.push("/useradd");
        }
        else{
            alert('失败');
        }
    })
}
</script>

